/**
 * 
 */
package org.jim.server.demo.school.service;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.jim.common.listener.ImBindListener;
import org.jim.common.packets.ChatBody;
import org.jim.common.packets.Group;
import org.jim.common.packets.User;
import org.jim.common.packets.UserMessageData;
import org.jim.server.demo.school.dao.MessageDao;
import org.jim.server.helper.redis.RedisImBindListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @author idmin
 *
 */
@Component
public class SPostgresqlMessageHelper implements SIMessageHelper {

	@Autowired
	private MessageDao dao;

	@Override
	public ImBindListener getBindListener() {
		return new RedisImBindListener();
	}

	@Override
	public boolean isOnline(String userid) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Group getGroupUsers(String group_id, Integer type) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Group> getAllGroupUsers(String user_id, Integer type) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Group getFriendUsers(String user_id, String friend_group_id, Integer type) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Group> getAllFriendUsers(String user_id, Integer type) {
		String string = dao.get("1");
		System.out.println(string);
		return null;
	}

	@Override
	public User getUserByType(String userid, Integer type) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void addGroupUser(String userid, String group_id) {
		Assert.notNull(userid, "用户id不能为空");
		Assert.notNull(group_id, "群组id不能为空");

		dao.addGroupUser(Integer.parseInt(userid), group_id);
	}

	@Override
	public List<String> getGroupUsers(String group_id) {
		if (StringUtils.isEmpty(group_id))
			return new ArrayList<String>();
		return null;
	}

	@Override
	public List<String> getGroups(String user_id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void writeMessage(String timelineTable, String timelineId, ChatBody chatBody) {
		// TODO Auto-generated method stub

	}

	@Override
	public void removeGroupUser(String userid, String group_id) {
		// TODO Auto-generated method stub

	}

	@Override
	public UserMessageData getFriendsOfflineMessage(String userid, String fromUserId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public UserMessageData getFriendsOfflineMessage(String userid) {
		if (StringUtils.isEmpty(userid))
			return null;
		return null;
	}

	@Override
	public UserMessageData getGroupOfflineMessage(String userid, String groupid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public UserMessageData getFriendHistoryMessage(String userid, String fromUerId, Double beginTime, Double endTime,
			Integer offset, Integer count) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public UserMessageData getGroupHistoryMessage(String userid, String groupid, Double beginTime, Double endTime,
			Integer offset, Integer count) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public User getUser(String username, String password) {
		String string = dao.get(username);
		return null;
	}

	@Override
	public List<Group> getAllGroupByUser(String userId) {
		if (StringUtils.isEmpty(userId))
			return new ArrayList<Group>();
		return dao.getAllGroupByUser(Integer.parseInt(userId));
	}

	@Override
	public List<User> getAllUserByUser(String userId) {
		if (StringUtils.isEmpty(userId))
			return new ArrayList<User>();
		return dao.getAllUserByUser(Integer.parseInt(userId));
	}

}
